home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************************************
- *
- *
- * ObjectMacZapp -- a standard Mac OOP application template
- *
- *
- *
- * ZScroller.h -- a window with scrollbars
- *
- *
- *
- *
- *
- * © 1996, Graham Cox
- *
- *
- *
- *
- *************************************************************************************************/
-
-
- #pragma once
-
- #ifndef __ZSCROLLER__
- #define __ZSCROLLER__
-
- #ifndef __ZDRAGDROPWINDOW__
- #include "ZDragDropWindow.h"
- #endif
-
- /*
- ZScroller is a window that has scrollbars in the usual way. The scrollBounds sets the size
- of the area that the window can show- if this is ever less than the window content the
- scrollbars will be disabled. The scale values set how many pixels to move in each direction
- for each increment of the scrollbar. Override this class to implement scrolling windows with
- REAL content.
- */
-
-
- class ZScroller : public ZDragDropWindow
- {
- protected:
- ControlHandle theHBar;
- ControlHandle theVBar;
- Rect bounds;
- short hScale;
- short vScale;
- Boolean hasHBar;
- Boolean hasVBar;
- short cInitValue;
-
- public:
-
- ZScroller( ZCommander* aBoss,
- const short windID,
- const Boolean hasHScroll = TRUE,
- const Boolean hasVScroll = TRUE );
-
- virtual void InitZWindow();
- virtual void Activate();
- virtual void Deactivate();
- virtual void Draw();
- virtual void DrawGrow();
- virtual void Click( const Point mouse, const short modifiers );
- virtual void SetSize( const short width, const short height, const Boolean reDraw = TRUE);
- virtual void Zoom( const short partCode );
- virtual void SetBounds( const Rect& aBounds );
- virtual void GetBounds( Rect* aBounds );
- virtual void SetScrollAmount( const short hAmount, const short vAmount );
- virtual void GetPosition( short* hPosition, short* vPosition );
- virtual void ScrollTo( const short hPosition, const short vPosition );
- virtual void GetContentRect( Rect* aRect );
- virtual void ClickContent( const Point mouse, const short modifiers );
- virtual void Scroll( const short dH, const short dV );
-
- protected:
-
- virtual void CalculateControlParams();
- virtual void MakeScrollbars();
- virtual void MoveScrollbars();
- virtual void PostScroll( ControlHandle aCtl = NULL );
- virtual void SetOriginToScroll();
-
- public:
-
- virtual void ScrollHandler( const ControlHandle aCtl, const short partCode );
- };
-
-
-
- // compiler flags:
-
- // ZScroller by default sets up a thumb action procedure to implement "live scrolling". If you'd
- // prefer to use the more traditional non-live scrolling, undefine the following conditional.
-
- #define _LIVE_SCROLLING 1
-
- // for live scrolling we require a UPP definition for the thumb proc- Apple's interfaces
- // omit this, so we do that here
-
- #ifdef _LIVE_SCROLLING
-
- #define kWidthOfScrollArrow 24
-
- // UPP:
-
- typedef pascal void (*ThumbActionProcPtr)();
-
- #if GENERATINGCFM
- typedef UniversalProcPtr ThumbActionUPP;
- #else
- typedef ThumbActionProcPtr ThumbActionUPP;
- #endif
-
- enum
- {
- uppThumbActionProcInfo = kPascalStackBased
- };
-
- #if GENERATINGCFM
- #define NewThumbActionProc(userRoutine) \
- (ThumbActionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppThumbActionProcInfo, GetCurrentArchitecture())
- #else
- #define NewThumbActionProc(userRoutine) \
- ((ThumbActionUPP) (userRoutine))
- #endif
-
- #if GENERATINGCFM
- #define CallThumbActionProc(userRoutine) \
- CallUniversalProc((UniversalProcPtr)(userRoutine), uppThumbActionProcInfo )
- #else
- #define CallThumbActionProc(userRoutine ) \
- (*(userRoutine))()
- #endif
-
-
- #endif
-
- #endif